package com.xhs.message;

/**
 * @desc: 全局状态码和msg
 * @projectName: tools-parent
 * @author: xhs
 * @date: 2022/12/3 21:05
 * @version: JDK 1.8
 */
public enum Result {

    /**
     * 成功的状态码 200
     */
    SUCCESS(200, "操作成功"),
    ADD_SUCCESS(200, "新增成功"),
    DEL_SUCCESS(200, "删除成功"),
    UPD_SUCCESS(200, "更新成功"),
    QUERY_SUCCESS(200, "查询成功"),
    DOWNLOAD_FILE_SUCCESS(200, "下载成功"),
    COPY_SUCCESS(200, "拷贝成功"),
    EXPORT_SUCCESS(200, "导出成功"),
    UPLOAD_FILE_SUCCESS(200, "文件上传成功"),
    ZIP_FILE_SUCCESS(200, "文件压缩成功"),
    SING_SUCCESS(200, "生成签名成功"),

    /**
     * 失败的状态码 9开头 4位
     */
    ERROR(9999, "系统异常"),
    ADD_ERROR(9998, "新增失败"),
    DEL_ERROR(9997, "删除失败"),
    UPD_ERROR(9996, "更新失败"),
    DOWNLOAD_FILE_ERROR(9995, "下载文件异常"),
    EXPORT_ERROR(9994, "导出失败"),
    UPLOAD_FILE_ERROR(9993, "文件上传异常"),
    SING_ERROR(9992, "生成签名失败"),
    NOT_KEY(9991,"key不存在"),
    ;


    /**
     * 状态码
     */
    private Integer code;

    /**
     * msg消息
     */
    private String msg;


    Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public Result formatMsg(String str) {
        this.msg = str;
        return this;
    }
}
